//
//  MethodTool.h
//  BeiChenLive
//
//  Created by 洪钻 on 2021/4/20.
//

#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonCryptor.h>


typedef void(^MyImageBlock)(UIImage * _Nullable image);

NS_ASSUME_NONNULL_BEGIN

@interface MethodTool : NSObject

/**获取手机当前显示的ViewController*/
+ (UIViewController*)getcurrentViewController;
/**视图转成image（模糊）*/
+(UIImage *)capturImageWithUIView:(UIView *)view;
/**视图转成image（清晰）*/
+(UIImage*)convertViewToImage:(UIView*)view;
/**压缩图片*/
+ (NSData *)compressOriginalImage:(UIImage *)image toMaxDataSizeKBytes:(CGFloat)size;
/**生成二维码*/
+ (UIImage*)createQRWithString:(NSString*)text QRSize:(CGSize)size;

+(UIImage *)getScrollViewImage:(UIScrollView *)scrollView;

/** 汉字转拼音之后，截取首字母，并大写*/
+(NSString *)transformCharacter:(NSString*)sourceStr;

+(UIImage *)getVideoFirstImageWithURL:(NSURL *)url;
+ (void)getThumbnailImage:(NSURL *)videoURL completion:(MyImageBlock)handler;
/**
 获取视频时长
 */
+ (NSInteger)getVideoTimeByUrlString:(NSString *)urlString;

+(void)playVideoWithURL:(NSString *)videoUrl;

+ (NSDictionary *)getVideoInfoWithSourcePath:(NSString *)path;

+(void)alertTitle:(NSString *)title;
+(void)alertTitle:(NSString *)title complete:(void (^)(UIAlertAction * _Nonnull action))complete;
+(void)alertTitle:(NSString *)title array:(NSArray *)array complete:(void (^)(NSInteger index ))complete;

+(BOOL)isEmpty:(id)object;


/**
 textfield 截取
 */
+(void)interceptTextField:(UITextField *)textField textLength:(NSInteger)textLength;
/**
 textView 截取
 */
+(void)interceptTextView:(UITextView *)textView textLength:(NSInteger)textLength;
@end

NS_ASSUME_NONNULL_END
